/* var container = document.getElementById("container");
container.addEventListener("touchmove" , function(event){
	event.preventDefault();
	})
 */

String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function checkPhone(phone){ 
	if(!(/^1[3|4|5|6|7|8|9]\d{9}$/.test(phone))){ 
	return false; 
	}else{
		return true;
		} 
}
function setCss3 (obj,attrObj) {
   for (var i in attrObj) {
     var newi=i;
	 if(newi.indexOf("-")>0){
	   var num=newi.indexOf("-");
	   newi=newi.replace(newi.substr(num,2),newi.substr(num+1,1).toUpperCase());
	 }
	 obj.style[newi]=attrObj[i];
	 newi=newi.replace(newi.charAt(0),newi.charAt(0).toUpperCase());
	 obj.style["webkit"+newi]=attrObj[i];
	 obj.style["moz"+newi]=attrObj[i];
	 obj.style["o"+newi]=attrObj[i];
	 obj.style["ms"+newi]=attrObj[i];
   }
  }
var _bgm = document.getElementById('bgm'); //比格牛牛游戏音效
$(function(){
	var _fenm=document.getElementById("fen");var _pengm=document.getElementById("peng");var ios=os.ios;window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;var posarr=[0,1,0,1,0,1];var sn=1;var wh=$(window).height();var ww=$(window).width();var floorArr=[];var lock=true;var fw=(ww/wh)*3660+ww-100;var score=0;var newPlay=true;var stage=new C3D.Stage();stage.size(ww,wh).material({color:""}).update();document.getElementById("gamebox").appendChild(stage.el);var content=document.getElementById("content");var animal=$(".animal");var space=new C3D.Sprite();space.position(0,330,-3920).rotation(-50,0,0).update();stage.addChild(space);insertFloor();function insertFloor(){for(var i=0;i<6;i++){var z=i*360+i*60;createFloor({z:z,index:i+1})}}var antop=wh-(ww/fw)*600;var mleft=ww/2;animal.css({bottom:(ww/fw)*600});var atop=0;var n=0;var sx=0;var mx=0;var aleft=0;var jumpTop=120;var astep=6;var floorStep=10.5;function createFloor(options){var floor=new C3D.Plane();var z=options.z;var name="floor"+options.index;if(ios){floor.name(name).size(fw,360).position(0,0,z).rotation(60,0,0).material({image:"images/floor.png"}).update();floor.el.className="floor"}else{floor.name(name).size(fw,360).position(0,0,z).rotation(60,0,0).material().update();floor.el.className="floor";floor.el.style.zIndex=0;var img=new Image();img.src="images/floor.png";img.className="floorbg";floor.el.appendChild(img)}addObject2(floor,(options.index-1));space.addChild(floor);floorArr.push(floor)}function addObject(floor){var objfloor=objarr[Math.floor(Math.random()*objarr.length)];var m=new C3D.Plane();m.type=objfloor.type;var imgw=objfloor.width;var imgh=objfloor.height;var lr=posarr[Math.floor(Math.random()*(posarr.length))];if(lr==0){var x=fw/5+imgw*3.5*Math.random()}else{var x=fw*0.8-imgw*3.5*Math.random()}if(!ios){m.el.style.zIndex=101;m.size(imgw*4,imgh*4).position(x,-imgh*1.2,155).rotation(0,0,0).material().update();var img=new Image();img.src=objfloor.src;img.className="zaw";m.el.appendChild(img)}else{m.el.style.zIndex=101;m.size(imgw*4,imgh*4).position(x,-imgh*1.2,155).rotation(0,0,0).material({image:objfloor.src}).update()}m.title=objfloor.title;m.des1=objfloor.des1;m.des2=objfloor.des2;floor.addChild(m);var m2=new C3D.Plane();var objmoney=moneyarr[Math.floor(Math.random()*moneyarr.length)];m2.type=objmoney.type;var imgw2=objmoney.width;var imgh2=objmoney.height;if(lr==0){var x2=fw*0.95-fw*0.3*Math.random()}else{var x2=fw*0.05+fw*0.3*Math.random()}if(!ios){m2.el.style.zIndex=100;m2.size(imgw2*3,imgh2*3).position(x2,-imgh2+50,155).rotation(0,0,0).material().update();var img22=new Image();img22.src=objmoney.src;img22.className="money";m2.el.appendChild(img22)}else{m2.size(imgw2*3,imgh2*3).position(x2,-imgh2+50,155).rotation(0,0,0).material({image:objmoney.src}).update()}floor.addChild(m2)}function moveFloor(fn){for(var i=0;i<floorArr.length;i++){floorArr[i].z=floorArr[i].z+floorStep;floorArr[i].el.style.opacity=1;floorArr[i].position(0,0,floorArr[i].z).updateT();if(floorArr[i].z>=2520){floorArr[i].el.style.opacity=0;floorArr[i].removeAllChild();floorArr[i].z=0;if(score>20){astep=8;floorStep=14}if(!ios){for(var m=0;m<floorArr.length;m++){if(m<i){floorArr[m].el.style.zIndex=6-i}else{floorArr[m].el.style.zIndex=Math.abs(5-i)}}}addObject(floorArr[i])}pzfn(floorArr[i],i)}}function pzfn(o,i){var floortop=o.el.getBoundingClientRect().top;var floorWidth=o.el.getBoundingClientRect().width;var floorHeight=o.el.getBoundingClientRect().height;if(floortop>(antop-floorHeight/2.5)&&floortop<=antop){for(var c=0;c<o.children.length;c++){var cheight=o.children[c].el.getBoundingClientRect().height;var ctop=o.children[c].el.getBoundingClientRect().top+cheight;var cwidth=o.children[c].el.getBoundingClientRect().width;var cleft=o.children[c].el.getBoundingClientRect().left;if(mleft>=cleft&&mleft<=(cleft+cwidth)){if(o.children[c].type=="kill"){lock=true;_pengm.play();$(".playendTxt1").html(o.children[c].title);$(".playendTxt2").html(o.children[c].des1);$(".playendTxt3").html(o.children[c].des2);$(".animalzhenmian").css({display:"none"});$(".animaldengxia").css({display:"none"});$(".animalbeimian").css({display:"none"});$(".animalku").css({display:"block"});$(".zhibojian, .paihangbang, .gonggao, .wodezhandui").css({display:"block"});setCss3(animal[0],{"transform":"translate3d(-50%,0,0)"});_pausebgM();setTimeout(function(){atop=0;astep=6;floorStep=10.5;setCss3(animal[0],{"transform":"translate3d(-50%,0,0)"});$(".startBtn").css({display:"none"});$(".replaybox").css({display:"block"});$(".startbox").css({display:"block"});$.post("api/?c=pz",{s:score},function(data){},"json")},200)}else{if(o.children[c].type=="money"){score=score+2;$(".scorebox").text(score);$(".scorebox2").text(score);o.children[c].remove();_fenm.play()}}}}}}$(".replay").click(function(e){lock=false;_playbgM();$(".animalzhenmian").css({display:"block"});$(".animaldengxia").css({display:"none"});
	$(".animalbeimian").css({display:"none"});$(".animalku").css({display:"none"});btnAnim2($(this),e,function(){atop=0;astep=6;floorStep=10.5;lock=true;mleft=ww*0.5;if(newPlay){newPlay=false;$(".replay").attr("src","images/replay-btn-2.png")}else{newPlay=true;score=0;$(".replay").attr("src","images/replay-btn.png");$(".scorebox").text(score);$(".scorebox2").text(score)}console.log(newPlay,score);$(".replay").text(score);for(var i=0;i<floorArr.length;i++){floorArr[i].removeAllChild();var z=i*360+i*60;floorArr[i].z=z;floorArr[i].el.style.opacity=1;floorArr[i].position(0,0,floorArr[i].z).updateT();addObject2(floorArr[i],i)}$(".startbox").css({display:"none"});animal.css({left:ww*0.5});djs321fn(function(){$(".animalzhenmian").css({display:"none"});$(".animaldengxia").css({display:"none"});$(".animalbeimian").css({display:"block"});$(".animalku").css({display:"none"});setTimeout(function(){$(".zhibojian, .paihangbang, .gonggao, .wodezhandui").css({display:"none"});lock=false;animate()},500)})})});$(".replayShowphb").click(function(e){_setPai(2,e);$(".replaybox, .startbox").fadeOut()});$(".rplaybtn").click(function(){$(".newrecordbox").css({display:"none"})});function animalAnim(){if(atop>=jumpTop){$(".animaldengxia").css({display:"none"});$(".animalbeimian").css({display:"block"});astep=-Math.abs(astep)}else{if(atop<=0){$(".animaldengxia").css({display:"block"});$(".animalbeimian").css({display:"none"});astep=Math.abs(astep)}}if(lock){$(".animaldengxia").css({display:"none"})}atop=atop+astep;setCss3(animal[0],{"transform":"translate3d(-50%,-"+atop+"px,0)"})}function animate(){if(lock){return}moveFloor();animalAnim();requestAnimationFrame(animate)}var _canPlayMp3=true;var _isPlay=false;function _playbgM(){if(false==_canPlayMp3){return}_isPlay=true;_bgm.play();$(".pBgm1").show();$(".pBgm2").hide()}function _pausebgM(){_isPlay=false;_bgm.pause();$(".pBgm2").show();$(".pBgm1").hide()}$(".bgmbox").click(function(){console.log(_isPlay);if(_isPlay){_bgm.pause();$(".pBgm2").show();$(".pBgm1").hide();_canPlayMp3=false;_isPlay=false}else{_bgm.play();$(".pBgm1").show();$(".pBgm2").hide();_canPlayMp3=true;_isPlay=true}});$(".startBtn").click(function(e){_playbgM();btnAnim($(this),e);setTimeout(function(){$(".startbox").css({display:"none"});djs321fn(function(){$(".animalzhenmian").css({display:"none"});$(".animaldengxia").css({display:"none"});$(".animalbeimian").css({display:"block"});$(".animalku").css({display:"none"});setTimeout(function(){lock=false;animate();$(".zhibojian, .paihangbang, .gonggao, .wodezhandui").css({display:"none"});$(".startbox").css({background:"rgba(0,0,0,0.6)","z-index":1005})},500)})},300)});addEventfn();function addEventfn(){document.addEventListener("touchstart",startfn,false);document.addEventListener("touchmove",movefn,false);document.addEventListener("touchend",endfn,false)}function startfn(e){e.preventDefault();if(lock){return}aleft=animal[0].offsetLeft;sx=e.touches[0].pageX;mx=sx}function movefn(e){e.preventDefault();if(lock){return}mx=e.touches[0].pageX;mleft=aleft+(mx-sx);if(mleft<20||mleft>ww-20){$(".startBtn").css({display:"none"});$(".replay").css({display:"block"});$(".startbox").css({display:"block"});lock=true;_pengm.play();$(".playendTxt1").html(wtitle);$(".playendTxt2").html(wdesc1);$(".playendTxt3").html(wdesc2);$(".animalzhenmian").css({display:"none"});$(".animalbeimian").css({display:"none"});$(".animaldengxia").css({display:"none"});$(".animalku").css({display:"block"});$(".zhibojian, .paihangbang, .gonggao").css({display:"block"});setCss3(animal[0],{"transform":"translate3d(-50%,0,0)"});_pausebgM();setTimeout(function(){atop=0;astep=6;floorStep=10.5;setCss3(animal[0],{"transform":"translate3d(-50%,0,0)"});$(".startBtn").css({display:"none"});$(".replaybox").css({display:"block"});$(".startbox").css({display:"block"});$.post("api/?c=pz",{s:score},function(data){},"json")},200)}animal.css({left:mleft})}function endfn(){mx=sx};

	//**********************************************************************************************************
	
	
	$(".rplaybtn").click(function(){
		$(".newrecordbox").fadeOut();
	})
	
	var sended = false;
	var sendTimer=null;
	$(".getYzm").click(function (){
		var _this = $(this);
		var tel = $(".inputnumber").val().trim();
		if(tel==""){
			icom.alert("手机号不能为空")
			return;
		}
		if(sended==false){
			$.post("api/?c=getcode", {p:tel}, function(data){
    			if('y' == data.s){
    				djsfn(_this)
    		}}, "json");
		}
	})
	
	
	function djsfn(_this){
		sended=true;
		var num=10;
		_this.addClass("sendActive");
		_this.html("发送验证码"+num+"s");
		sendTimer=setInterval(function (){
			num--;
			if(num==0){
				_this.removeClass("sendActive").html("发送验证码");
				sended=false;
				clearInterval(sendTimer);
				}else{
					_this.html("发送验证码"+num+"s");
					}
			
			},1000)
		
		
	}
	
	
	$(".loginbgn").click(function(){
		var tel = $(".inputnumber").val().trim();
		var yzm = $(".inputtext").val().trim();
		console.log(tel , yzm);
		if(tel==""){
			icom.alert("手机号不能为空")
			return;
		}
		if(yzm==""){
			icom.alert("验证码不能为空")
			return;
		}
		$.post("api/?c=setphone", {p:tel, code:yzm}, function(data){
			if('y' == data.s){
				$(".loaddatabox").css({display:"block"})
				setTimeout(function(){
					$(".loaddatabox").css({display:"none"})
					$(".loginbox").fadeOut();
				},100);
			}else{
				if('code' == data.e){
					icom.alert("输入的验证码不正确")
					return;
				}
			}
		}, "json");	
	})
	
	$(".sharebtn").click(function(){
		$(".sharefloat").css({display:"block"})
	})
	
	$(".sharefloat")[0].addEventListener("touchend" , function(){
		$(".sharefloat").css({display:"none"})
	},false)
	
	
	$(".zhibojian").click(function(){ // 进直播间
		$(".zhibojianbox").fadeIn();
	})
	$(".zhibojianback").click(function(){
		$(".zhibojianbox").fadeOut();
	})
	
	
	//公告
	var ggscroll = new BScroll('.ggscrollbox2',{//我的排行榜滚动条
	    scrollY: true,
	    scrollbar: {
		 fade: true,
		 interactive: false // 1.8.0 新增
		},
		click: true,/*允许点击事件*/
		startY:0, /*滚动的起始位置*/
		bounce:true, /*回弹动画*/
	})
	
	loadedimg("images/gg02.png" , function(){
		ggscroll.refresh();
	})
	
	
	$(".gonggao").click(function(){
		$(".gonggaobox").fadeIn(function(){
			ggscroll.refresh();
		})
	})
	
	$(".closegonggao").click(function(){
		$(".gonggaobox").fadeOut()
	})
	//打开协议
	var xyscroll = new BScroll('.xieyioutbox',{//我的排行榜滚动条
	    scrollY: true,
	    scrollbar: {
		 fade: true,
		 interactive: false // 1.8.0 新增
		},
		click: true,/*允许点击事件*/
		startY:0, /*滚动的起始位置*/
		bounce:true, /*回弹动画*/
	}) 
	
	$(".xieyibtn").click(function(){
		$(".xieyibox").fadeIn(function(){
			xyscroll.refresh();
		})
	})
	$(".xieyibox").click(function(){
		$(".xieyibox").fadeOut()
	})
	//排行榜
	var scrollogr = new BScroll('.grScrollbox',{//我的排行榜滚动条
	    scrollY: true,
	    scrollbar: {
		 fade: true,
		 interactive: false // 1.8.0 新增
		},
		click: true,/*允许点击事件*/
		startY:0, /*滚动的起始位置*/
		bounce:true, /*回弹动画*/
	})
	var scrollogroup= new BScroll('.groupScrollbox',{//战队排行榜滚动条
	    scrollY: true,
	    scrollbar: {
		 fade: true,
		 interactive: false // 1.8.0 新增
		},
		click: true,/*允许点击事件*/
		startY:0, /*滚动的起始位置*/
		bounce:true, /*回弹动画*/
	})
	function _setPai(_flag,e){ //_flag 调用来源区分
		var _this=this;
		$.post("api/?c=getpai", {id:1}, function(data){
			var _html='';
			$(".listUlbox1").html("");
			if('' != data.p){
				for(var i=0;i<data.p.length;i++){
					if(1 == data.p[i].hj){
						_html+='<li class="listItem listItemFront3 listItemFront3-1"><div class="listUserheaderbox3"><img src="'+data.p[i].a+'" /></div>';
						_html+='<img src="images/'+(i+1)+'.png" class="layer123" /><div class="layerName">'+data.p[i].n+'</div><div class="layerScore">'+data.p[i].f+'</div><img src="images/icon-1.png" class="iconjp" /></li>';
					}else{
						_html+='<li class="listItem"><div class="listUserheaderbox"><img src="'+data.p[i].a+'" />';
							_html+='</div><div class="layernum">'+(i+1)+'</div><div class="layerName">'+data.p[i].n+'</div><div class="layerScore">'+data.p[i].f+'</div></li>';
						
					}
					console.log(data.p[i].n);
				}
				$(".listUlbox1").append(_html);
			}
			$(".myphmsg .layerScore0").text(data.fen);
			if(0 == data.up){
				$(".myphmsg .myLayer").hide();
				$(".myphmsg .noshangbang").show();
			}else{
				if(data.up < 4){
					$(".myphmsg .iconjp0").attr("src","images/icon-1.png");
				}else{
					$(".myphmsg .iconjp0").hide();
				}
				$(".myphmsg .myLayer").text(data.up);
				$(".myphmsg .noshangbang").hide();
			}
				
			if(1 == _flag){
				$(".paihangbangbox1").fadeIn(function(){
					setTimeout(function(){
						scrollogr.refresh();
						scrollogroup.refresh();
					},500)
				})
			}
			if(2 == _flag){
				btnAnim2($(_this),e , function(){
					$(".paihangbangbox1").fadeIn(function(){
						setTimeout(function(){
							scrollogr.refresh()
							scrollogroup.refresh();
						},500)
					})
				});
			}
			
			
			
		}, "json");
	}
	$(".paihangbang").click(function(e){
		_setPai(1,e);
	})
	$(".backphb").click(function(){
		$(".paihangbangbox1").fadeOut(function(){
		});
			$(".startbox, .startBtn").show();
			$(".startbox").css({background:"","z-index":""});
			$(".replaybox").fadeOut();
			$(".startBtn").show(function(){
				$(".replay").attr("src","images/replay-btn.png")
				$(".scorebox").text(score);
				$(".scorebox2").text(score);
			});
			
			atop=0;
			astep=6;
			floorStep=10.5;
			lock=true;
			mleft=ww*0.5;
			
			newPlay=true;
			score=0;
			$(".replay").text(score);
			$(".animalzhenmian").css({display:"block"});
			$(".animaldengxia").css({display:"none"});
			$(".animalbeimian").css({display:"none"});
			$(".animalku").css({display:"none"});
			for(var i=0;i<floorArr.length;i++){
				floorArr[i].removeAllChild();
				var z = i*360+i*60;
				floorArr[i].z=z;
				floorArr[i].el.style.opacity=1;
				floorArr[i].position(0,0,floorArr[i].z).updateT();
				addObject2(floorArr[i],i)
			} 
			
			animal.css({left:ww*0.5}); // 610
			
		
	})
	
	function _getZhanpai(){ //战队排名
		$.post("api/?c=getzhanpai", {id:1}, function(data){
			if(data.up > 0){
				$(".noshangbang").hide();
				$(".mygroupbox .myLayer").show().html(data.up);
			}else{
				$(".noshangbang").show();
				$(".mygroupbox .myLayer").hide();
			}
			$(".mygroupbox, .joinGroup").hide();
			if(data.id > 0){
				$(".mygroupbox .layerScore0").html(data.u.f);
				$(".mygroupbox .layerName0").html(data.u.n);
				$(".inshowGroupname").text(data.u.n)
				$(".mygroupbox").css({display:"block"});
			}else{
				$(".joinGroup").css({display:"block"})
			}
			var _html='';
			console.log(data.u.ua)
			if(typeof(data.u.ua) != 'undefined'){
				if(1 == data.u.ua.length){
					_html='<div class="groupHeader groupHeader1-1"><img src="'+data.u.ua[0]+'" /></div>';
				}
				if(2 == data.u.ua.length){
					_html='<div class="groupHeader groupHeader2-1"><img src="'+data.u.ua[0]+'" /></div><div class="groupHeader groupHeader2-2"><img src="'+data.u.ua[1]+'" /></div>';							
				}
				if(3 == data.u.ua.length){
					_html='<div class="groupHeader groupHeader3-1"><img src="'+data.u.ua[0]+'" /></div><div class="groupHeader groupHeader3-2"><img src="'+data.u.ua[1]+'" /></div><div class="groupHeader groupHeader3-3"><img src="'+data.u.ua[2]+'" /></div>';
				}
				$(".mygroupbox .gourpHeaderbox").html("").append(_html);
			}
			
			_html='';
			for(var i=0;i<data.t.length;i++){
				
				if(3 == data.t[i].a.length){
					_html+='<li class="listItem listItemFront3 listItemFront3-1">';
					_html+='<div class="listUserheaderbox3-3-1"><img src="'+data.t[i].a[0]+'" /></div><div class="listUserheaderbox3-3-2"><img src="'+data.t[i].a[1]+'" /></div><div class="listUserheaderbox3-3-3"><img src="'+data.t[i].a[2]+'" /></div>';
					
					var _jpHtml='';
					if(1 == data.t[i].hj){
					 _jpHtml='<img src="images/icon-1.png" class="iconjp" />';
					}
					if(i < 3){
						_html+='<img src="images/'+(i+1)+'.png" class="layer123" /><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div>'+_jpHtml+'</li>';
					}else{
						_html+='<div class="layernum">'+(i+1)+'</div><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div>'+_jpHtml+'</li>';
					}
				}
				if(2 == data.t[i].a.length){
				
					_html+='<li class="listItem listItemFront3 listItemFront3-1">';
					_html+='<div class="listUserheaderbox3-2-1"><img src="'+data.t[i].a[0]+'" /></div><div class="listUserheaderbox3-2-2"><img src="'+data.t[i].a[1]+'" /></div>';
					if(i < 3){
						_html+='<img src="images/'+(i+1)+'.png" class="layer123" /><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div><img src="images/icon-1.png" class="iconjp" /></li>';
					}else{
						_html+='<div class="layernum">'+(i+1)+'</div><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div><img src="images/icon-1.png" class="iconjp" /></li>';
					}
					
				}
				if(1 == data.t[i].a.length){
					
					_html+='<li class="listItem listItemFront3 listItemFront3-1">';
					_html+='<div class="listUserheaderbox3-1-1"><img src="'+data.t[i].a[0]+'" /></div>';
					if(i < 3){
						_html+='<img src="images/'+(i+1)+'.png" class="layer123" /><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div><img src="images/icon-1.png" class="iconjp" /></li>';
					}else{
						_html+='<div class="layernum">'+(i+1)+'</div><div class="layerName">'+data.t[i].n+'</div><div class="layerScore">'+data.t[i].f+'</div><img src="images/icon-1.png" class="iconjp" /></li>';
					}
					
				}
				console.log(data.t[i]);
			}
			$(".groupScrollbox .listUlbox2").html("").append(_html);
			
			console.log(data);
		}, "json");
	}
	
	$(".tab1").click(function(){
		var index = $(this).index();
		/* $(this).find(".tab1bg").css({display:"none"})
		$(this).find(".tab1bgactive").css({display:"block"})
		$(this).siblings(".tab1").find(".tab1bg").css({display:"block"})
		$(this).siblings(".tab1").find(".tab1bgactive").css({display:"none"}) */
		if(index==0){
			$(".phbboxbg").css({background:"#d1ebff"});
		}else{
			$(".phbboxbg").css({background:"#9fd3ff"});
			_getZhanpai(); //战队排名
		}
		tabchange(index);
		
	})
	
	function tabchange(index){
		if(index==0){
			$(".mymsgbox1").css({display:"block"})
			$(".groupmsgbox1").css({display:"none"})
			$(".grScrollbox").css({display:"block"})
			$(".groupScrollbox").css({display:"none"})
			setTimeout(function(){
				scrollogr.refresh();
			},500)
		}else{
			$(".mymsgbox1").css({display:"none"})
			$(".groupmsgbox1").css({display:"block"})
			$(".grScrollbox").css({display:"none"})
			$(".groupScrollbox").css({display:"block"})
			setTimeout(function(){
				scrollogroup.refresh();
			},500)
		}
		
		
	}
	
	function _openMyzhanDui(){
		$.post("api/?c=getzhan", {id:1}, function(data){
			if('y' == data.s){
				var _html='';
				for(var i=0;i<data.u.length;i++){
					_html+='<li class="myzdlistItem"><div class="listUserheaderbox3"><img src="'+data.u[i].a+'" /></div><div class="layerName">'+data.u[i].name+'</div><div class="layerScorezd">'+data.u[i].f+'</div>';
					if('y' == data.u[i].isf){
						_html+='<div class="outGroup">退出</div></li>';
					}else{
						_html+='</li>';
					}
				}
				if(3 == data.u.length){
					$(".sharebtnzdbtn").hide();
				}else{
					$(".sharebtnzdbtn").show();
				}
				$(".zhanduichengyuan").html('战队成员('+data.u.length+'/3)');
				$(".myzdpaiming").html('当前排名:'+data.up);
				$(".myzdlistUlbox").html(_html);
				$(".outGroup").click(function(){
					$(".querenoutgroup").fadeIn();
				});
				$(".wozaixiangxiang").click(function(){
					$(".querenoutgroup").fadeOut();
				});
				$(".queyiyijue").click(function(){
					$.post("api/?c=outgroup", {key:'yes'}, function(data){
						$('.myzhandui, .querenoutgroup').fadeOut();
					}, "json");
				});
				
                $(".myzdjifen span").html(data.fen);
				$(".myzhanduimsg .rentou").hide();
				if(1 == data.tou.length){
					$(".rentou1").show();
					$(".rentou1 img").attr("src",data.tou[0]);
				}
                if(2 == data.tou.length){
                	$(".rentou2-1, .rentou2-2").show();
                	for(var i=0;i<data.tou.length;i++){
    					$(".rentou2-"+(i+1)+" img").attr("src",data.tou[i]);
    				}
				}
                if(3 == data.tou.length){
                	$(".rentou3-1, .rentou3-2, .rentou3-3").show();
                	for(var i=0;i<data.tou.length;i++){
    					$(".rentou3-"+(i+1)+" img").attr("src",data.tou[i]);
    				}
				}
				$(".myzhanduimsg .myzhanduiname").html(data.tn);
				$(".inmyzhanduibox").show();
				$(".nozhanduibox").hide();
			}
			if('n' == data.s){
				$(".inmyzhanduibox").hide();
				$(".nozhanduibox").show();
			}
			
		}, "json");
	}
	
	//打开我的战队
	$(".wodezhandui").click(function(){
		_openMyzhanDui();
		$(".myzhandui").fadeIn();
	})
	
	//排行榜 加入战队
	$(".joinGroup").click(function(){
		$(".createGroup").css({display:"block"})
		$(".createsuccessbox").css({display:"none"})
		$(".createGroupbox").css({display:"block"})
	})
	
	function _popMsgOut(msg){
		$(".weui-toast__content").html(msg);
		$(".weui-toast").fadeIn();
		window.setTimeout(function(){
			$(".weui-toast").fadeOut();
		}, 1800);
	}
	
	$(".qrcreatebtn").click(function(){ // 点击创建战队确认按钮
		var groupName = $(".groupname").val().trim();
		if(groupName==""){
			_popMsgOut("战队名不能为空");
			return
		}
		$.post("api/?c=setteam", {name:groupName}, function(data){
			if('n' == data.s){
				if('name' == data.e){
					_popMsgOut("战队名已存在");
				}
				return;
			}
			$(".loaddatabox").css({display:"block"});
			_getZhanpai(); //战队排名
			_openMyzhanDui();
			setTimeout(function(){
				$(".groupname").val("");
				$(".inshowGroupname").text(groupName)
				$(".loaddatabox").css({display:"none"});
				$(".createGroup, .joinGroup").css({display:"none"})
				$(".createsuccessbox, .mygroupbox, .wodezhandui").css({display:"block"});
			},500);
		}, "json");
	})
	
	$(".showsharefloatbtn").click(function(){
		$(".sharefloat").fadeIn()
	})
	
	$(".closeCreategroupbox").click(function(){ // 关闭创建战队
		$(".createGroupbox").css({display:"none"})
		$(".createGroup").css({display:"block"})
		$(".createsuccessbox").css({display:"none"})
		
	})
	
	$(".backwdzd").click(function(){
		$('.myzhandui').fadeOut()
	})
	
	
	//通过分享进来 加入战队
	$(".querenjiarugroupbtn").click(function(){ // 确认加入
		$.post("api/?c=addgroup", {id:1}, function(data){
			$(".joinsharegroupbox").css({display:"none"});
			$(".joinsharegroupsuccessbox, .wodezhandui").css({display:"block"})
			
	        }, "json"); //last work
		
	})
	
	$(".chakanmyzhandui").click(function(){ // 查看我的战队
		$.post("api/?c=getzhan", {id:1}, function(data){
			if('y' == data.s){
				var _html='';
				for(var i=0;i<data.u.length;i++){
					_html+='<li class="myzdlistItem"><div class="listUserheaderbox3"><img src="'+data.u[i].a+'" /></div><div class="layerName">'+data.u[i].name+'</div><div class="layerScorezd">'+data.u[i].f+'</div>';
					if('y' == data.u[i].isf){
						_html+='<div class="outGroup">退出</div></li>';
					}else{
						_html+='</li>';
					}
				}
				if(3 == data.u.length){
					$(".sharebtnzdbtn").hide();
				}else{
					$(".sharebtnzdbtn").show();
				}
				$(".zhanduichengyuan").html('战队成员('+data.u.length+'/3)');
				$(".myzdpaiming").html('当前排名:'+data.up);
				$(".myzdlistUlbox").html(_html);
				$(".outGroup").click(function(){
					$(".querenoutgroup").fadeIn();
				});
				$(".wozaixiangxiang").click(function(){
					$(".querenoutgroup").fadeOut();
				});
				$(".queyiyijue").click(function(){
					$.post("api/?c=outgroup", {key:'yes'}, function(data){
						$('.myzhandui, .querenoutgroup').fadeOut();
					}, "json");
				});
				
                $(".myzdjifen span").html(data.fen);
				$(".myzhanduimsg .rentou").hide();
				if(1 == data.tou.length){
					$(".rentou1").show();
					$(".rentou1 img").attr("src",data.tou[0]);
				}
                if(2 == data.tou.length){
                	$(".rentou2-1, .rentou2-2").show();
                	for(var i=0;i<data.tou.length;i++){
    					$(".rentou2-"+(i+1)+" img").attr("src",data.tou[i]);
    				}
				}
                if(3 == data.tou.length){
                	$(".rentou3-1, .rentou3-2, .rentou3-3").show();
                	for(var i=0;i<data.tou.length;i++){
    					$(".rentou3-"+(i+1)+" img").attr("src",data.tou[i]);
    				}
				}
				$(".myzhanduimsg .myzhanduiname").html(data.tn);
				
			}
			if('n' == data.s){
				$(".inmyzhanduibox").hide();
				$(".nozhanduibox").show();
			}
			
			
			
			
			$(".sourceShareJoingroup").css({display:"none"})
			$(".myzhandui").css({display:"block"})
		}, "json");
	})
	
	$(".closerepeatbox").click(function(){
		$(".sourceShareJoingroup").fadeOut();
	})
	$(".closereplaybox").click(function(){
		$(".startbox").css({background:"","z-index":""});
		$(".replaybox").fadeOut();
		$(".startBtn").show(function(){
			$(".replay").attr("src","images/replay-btn.png")
			$(".scorebox").text(score);
			$(".scorebox2").text(score);
		});
		
		atop=0;
		astep=6;
		floorStep=10.5;
		lock=true;
		mleft=ww*0.5;
		
		newPlay=true;
		score=0;
		
		
		$(".replay").text(score);
		$(".animalzhenmian").css({display:"block"});
		$(".animaldengxia").css({display:"none"});
		$(".animalbeimian").css({display:"none"});
		$(".animalku").css({display:"none"});
		
		
		for(var i=0;i<floorArr.length;i++){
			floorArr[i].removeAllChild();
			var z = i*360+i*60;
			floorArr[i].z=z;
			floorArr[i].el.style.opacity=1;
			floorArr[i].position(0,0,floorArr[i].z).updateT();
			addObject2(floorArr[i],i)
		} 
		
		animal.css({left:ww*0.5}); // 610
		
		/* djs321fn(function(){
			setTimeout(function(){
		    $(".zhibojian, .paihangbang, .gonggao, .wodezhandui").css({display:"none"});
			lock=false;
			animate();
			},500)
		})	 */
	})
	
	
	//活动未开始
	$(".activeNotStartChakangonggao").click(function(){
		$(".gonggaobox").fadeIn()
	})
	
	//活动结束
	$(".closeendactivebox").click(function(){
		$(".endactivebox").fadeOut()
	})
	
	
	//
	$(".chuangjzdbtn").click(function(){
		$(".createGroupbox").fadeIn()
	})
	
	$(".sharebtnzdbtn").click(function(){
		$(".sharefloat").fadeIn();
	})
	
	
	function btnAnim(o,e){
	 e.preventDefault(0);
	 o.addClass("btnscale");
	 setTimeout(function(){
	  o.removeClass("btnscale")
	 },350)
	 }
	 
	 function btnAnim2(o,e , fn){
	 	 e.preventDefault(0);
	 	 o.addClass("btnscale2");
	 	 setTimeout(function(){
	 	  o.removeClass("btnscale2");
		  if(fn){
			  fn();
		  }
	 	 },150)
	 	 }
	
	
	
	function djs321fn(fn){ // 倒计时
		var n = 1;
		$(".daojishi").css({display:"block"})
		var timer = setInterval(function(){
			$("img.djsnum").eq(n).css({display:"block"}).siblings("img.djsnum").css({display:"none"});
			n++;
			if(n>3){
				clearInterval(timer);
				
				$(".daojishi").css({display:"none"});
				$("img.djsnum").eq(0).css({display:"block"}).siblings("img.djsnum").css({display:"none"});
				
				if(fn){
					fn();
				}
			}
		},1000)
	}
	
	function loadedimg(url , fn){
		var img = new Image();
		img.onload=function(){
			if(fn){
				fn();
			}
		}
		img.src=url;
	}
	
	
	
	function addObject2(floor,n){
		//var objfloor = objarr[Math.floor(Math.random() * objarr.length)];
		//console.log(objfloor)
		
		
		
		if(n==0){
			var objfloor = objarr[Math.floor(Math.random() * objarr.length)];
			var m=new C3D.Plane();
			m.type = objfloor.type;
			var imgw=objfloor.width;
			var imgh=objfloor.height;
			var x = fw*0.8 - imgw // 右侧显示障碍物 点
			
			if(!ios){
				m.el.style.zIndex=101
				m.size(imgw*4,imgh*4).position(x,-imgh,155).rotation(0,0,0).material().update();
				var img= new Image();
				img.src=objfloor.src
				img.className="zaw";
				m.el.appendChild(img)
			}else{
				m.el.style.zIndex=101
				m.size(imgw*4,imgh*4).position(x,-imgh,155).rotation(0,0,0).material({image:objfloor.src}).update();
			}
			m.title=objfloor.title;
			m.des1=objfloor.des1;
			m.des2=objfloor.des2;
			
			floor.addChild(m) 
		}
		
		//添加金币
		if(n==1){
			var m2=new C3D.Plane();
			var objmoney =moneyarr[Math.floor(Math.random() * moneyarr.length)]
			m2.type = objmoney.type;
			var imgw2 = objmoney.width;
			var imgh2 = objmoney.height;
			
				//var x2 = fw/5+imgw*2*Math.random() // 左侧显示金币
			var x2 =fw*0.05+fw*0.3 // 左侧显示金币
				
			
			if(!ios){
				m2.el.style.zIndex=100
				m2.size(imgw2*3,imgh2*3).position(x2,-imgh2+50,155).rotation(0,0,0).material().update();
				var img22= new Image();
				img22.src=objmoney.src
				img22.className="money";
				m2.el.appendChild(img22)
			}else{
				
				m2.size(imgw2*3,imgh2*3).position(x2,-imgh2+50,155).rotation(0,0,0).material({image:objmoney.src}).update();
			}
			floor.addChild(m2)
		}
		//setTimeout(function(){
		//floor.el.style.display="block"
		//},50)
		
		
		
	}
	
	
	})








